package codename.carrot.bomberman.game.gamemessages;

import java.util.HashMap;

import codename.carrot.bomberman.LevelDefinition;
import codename.carrot.bomberman.game.networkobjects.DroidPoint;

/**
 *  A message that contains all necessary information to start a game
 * @author Group A4
 *
 */
public class GameInitMessage extends BombermanMessage {
	/**
	 *  the UID for serialization
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * The definition of the level to be played on
	 */
	private LevelDefinition levelDefinition;
	/**
	 * The initial positions of all players
	 */
    private HashMap<Integer, DroidPoint> initialPositions = new HashMap<Integer, DroidPoint>();
    
    /**
     *  Constructor
     * @param levelDefinition the definition of the level to be played on
     * @param initialPositions the initial placement for all players
     */
    public GameInitMessage(LevelDefinition levelDefinition, HashMap<Integer, DroidPoint> initialPositions) {
        this.initialPositions = initialPositions;
        this.levelDefinition = levelDefinition;
    }          
    
    /**
     *  Returns the definition of the level to be played on
     * @return the level definition
     */
    public LevelDefinition getLevelDefinition() {
        return levelDefinition;
    }
        
    /**
     * Returns the initial X-coordinate for a player
     * @deprecated Use getInitialPlayerPosition instead
     * @param playerId the ID of the player to return coordinate for
     * @return initial x-coordinate
     */
    public int getInitialXcoorMap(int playerId) {
        DroidPoint initialPosition = initialPositions.get(playerId);
        return initialPosition.x;
    }
    
    /**
     * Returns the initial Y-coordinate for a player
     * @deprecated Use getInitialPlayerPosition instead
     * @param playerId the ID of the player to return coordinate for
     * @return initial y-coordinate
     */
    public int getInitialYcoorMap(int playerId) {
        DroidPoint initialPosition = initialPositions.get(playerId);
        return initialPosition.y;
    }
    
    /**
     *  Returns the initial position of a player
     * @param playerId the ID of the player to return initial position for
     * @return initial position
     */
    public DroidPoint getInitialPlayerPosition(int playerId) {
        return initialPositions.get(playerId);
    }    
}
